import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/pages/home'
import Search from '@/pages/search'
import Login from '@/pages/login'
import Register from '@/pages/register'
Vue.use(VueRouter)

const push = VueRouter.prototype.push

VueRouter.prototype.push = function (loaction) {
    push.call(this,loaction,()=>{},(err)=>{})
}

export default new VueRouter({
    mode: 'hash',
    routes: [
        {
            path: '/home',
            component: Home,
            meta: {
                isActive: true
            }
        },
        {
            name: 'search',
            path: '/search/:keyword?',
            component: Search,
            meta: {
                isActive: true
            },
            // props:true
            // props:{a:1}
            props(route) {
                return route.params
            }
        },
        {
            path: '/login',
            component: Login,
            meta: {
                isActive: false
            }
        },
        {
            path: '/register',
            component: Register,
            meta: {
                isActive: false
            }
        },
        {
            path: '/',
            redirect: '/home'
        }
    ]
})